package com.example.message.handler;

import com.example.message.service.SysMessageService;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.IOException;

@Service
public class SysMessageServicesHandler extends AbstractSysMessageHandler {

    Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public String getName() {
        return SysMessageService.SERVICES;
    }

    @Override
    public void receive(String fileName) {
        File file = new File(getFilePath() + File.separatorChar + getName() + File.separatorChar + fileName);
        if (file.exists()) {
            try {
                String context = FileUtils.readFileToString(file);
                logger.warn("SysMessageServicesHandler 收到消息:" + context);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
